﻿#pragma once

#include "../MirEnvir/Envir.h"
#include "../MessageQueue.h"
#include "MonsterInfo.h"
#include "../../Shared/Globals.h"
#include "../../Shared/Data/ItemData.h"
#include <string>
#include <vector>
#include <algorithm>
#include "../../stringhelper.h"
#include "../../tangible_filesystem.h"

using namespace Server::MirEnvir;

namespace Server::MirDatabase
{
    class DragonInfo
    {
    public:
        virtual ~DragonInfo()
        {
            delete Location;
            delete DropAreaTop;
            delete DropAreaBottom;
        }

    protected:
        static Server::MirEnvir::Envir *getEnvir();

        static Server::MessageQueue *getMessageQueue();

    public:
        bool Enabled = false;
        std::string MapFileName, MonsterName, BodyName;
        Point *Location, *DropAreaTop, *DropAreaBottom;
        std::vector<std::vector<DropInfo*>> Drops = std::vector<std::vector<DropInfo*>>(Globals::MaxDragonLevel);
        std::vector<long long> Exps = std::vector<long long>(Globals::MaxDragonLevel - 1);

        unsigned char Level = 0;
        long long Experience = 0;

        DragonInfo();
        DragonInfo(BinaryReader *reader);
        void Save(BinaryWriter *writer);

        void LoadDrops();

    public:
        class DropInfo
        {
        public:
            int Chance = 0;
            ItemInfo *Item;
            unsigned int Gold = 0;
            unsigned char level = 0;

            virtual ~DropInfo()
            {
                delete Item;
            }

            static DropInfo *FromLine(const std::string &s);
        };
    };
}
